package com.haochang.chunkvod.tools.vod.thread;

import java.util.ArrayList;
import java.util.List;

import com.haochang.chunkvod.app.database.cash.PrintInfoDao;
import com.haochang.chunkvod.app.utils.CollectionUtils;
import com.haochang.chunkvod.model.cash.PrintEnum;
import com.haochang.chunkvod.model.cash.PrintInfo;
import com.haochang.chunkvod.tools.thirdparty.lakala.ThirdPrintUitls;


/**
 *@author qintao
 *created at 2016/9/14 16:22
 * 打印线程
 */

public class PrintThread extends Thread
{
	private PrintEnum printEnum;//打印类型
	private PrintInfo printInfo = null;//打印信息
	private List<PrintInfo> printInfoList = new ArrayList<PrintInfo>();//打印信息

	public PrintThread(PrintEnum printEnum, PrintInfo printInfo)
	{
		this.printInfo = printInfo;
		this.printEnum = printEnum;
	}

	public PrintThread(PrintEnum printEnum)
	{
		this.printEnum = printEnum;
	}

	public PrintThread(PrintEnum printEnum, List<PrintInfo> printInfoList)
	{
		if (!CollectionUtils.isEmpty(printInfoList))
		{
			this.printInfoList.clear();
			this.printInfoList.addAll(printInfoList);
		}
		this.printEnum = printEnum;
	}

	@Override
	public void run()
	{
		super.run();
		startPrint(printEnum);
	}

	/**
	 * PrintEnum printEnum;//打印类型
	 */
    private void startPrint(PrintEnum printEnum){
	switch (printEnum)
	{
		case PRINT_DB:
			ThirdPrintUitls.printDBInfo(printInfoList);
			break;
		case PRINT_PAY:
			ThirdPrintUitls.printPaiedInfo(printInfo);
			break;
		case PRINT_CHECK_OUT:
			ThirdPrintUitls.printCheckOutInfo(printInfo);
			break;
		case PRINT_COLLECT:
			ThirdPrintUitls.printCollectInfo(printInfo);
			break;
		case PRINT_SHIFT:
			ThirdPrintUitls.printShiftInfo(printInfo);
			break;
		case CASH_MONEY:
			ThirdPrintUitls.printShiftCashInfo(printInfo);
			break;
		case PRINT_PRE_PAY:
			ThirdPrintUitls.printPrePayInfo(printInfo);
			break;
		case PRINT_URGENCY:
			printInfoList = PrintInfoDao.getDao().queryBuilderAll(PrintInfo.class, "type", printEnum.PRINT_URGENCY.getName());
			ThirdPrintUitls.printUrgencyInfo(printInfoList);
			break;
		case PRINT_PRE_CHECK_OUT:
			ThirdPrintUitls.printPreCheckOutInfo(printInfo);
			break;
		case PRINT_HOSTESS_ONE_KEY_OPEN_ROOM://打印咨客--按房型开房
			ThirdPrintUitls.printOneKeyOpenRoomInfo(printInfo);
			break;
		default:
			break;
	}
}
}
